package com.sr.examination.main;

import android.os.Bundle;
import android.view.View;

import com.tl.commonlibrary.ui.BaseFragment;

/**
 * @author JongSung
 * @Description 主界面除底部导航栏外的内容模块：包含Viewpager，买卖功能，其他等
 * @date 2017/6/6 0006.
 */

public class MainContentViewModel {
    private MainActivity activity;
    private MainPageViewModel pageModel; //主界面
    private MainOtherViewModel otherModel;//其他：服务

    public MainContentViewModel(MainActivity mainActivity) {
        this.activity = mainActivity;
        pageModel = new MainPageViewModel(mainActivity);//主界面 Tab Fragment
        otherModel = new MainOtherViewModel(mainActivity);
    }

    /**
     * Activity被系统回收重建时恢复内容模块的数据
     *
     * @param savedInstanceState
     */
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        pageModel.onRestoreInstanceState(savedInstanceState);
    }

    public BaseFragment getFragment(Item item) {
        return pageModel.getFragment(item);
    }

    /**
     * @param item 当前需要展示的item
     */
    public void showFragment(Item item) {
        pageModel.showFragment(item);
    }

    public void exit() {
        otherModel.exit();
    }

    public void init(boolean isReOnCreate) {
        otherModel.init(isReOnCreate);
    }

    public void permissionFailed(int requestCode) {
        otherModel.permissionFailed(requestCode);
    }

    public void permissionSuccess(int requestCode) {
        otherModel.permissionSuccess(requestCode);
    }

}
